home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / gg / ncurses-5.3.lha / ncurses-5.3 / misc / chkdef.cmd next >
OS/2 REXX Batch file  |  2002-10-24  |  2KB  |  87 lines

  1. /*
  2.  * $Id: chkdef.cmd,v 1.2 1998/08/29 21:45:58 tom Exp $
  3.  *
  4.  * Author:  Juan Jose Garcia Ripoll <worm@arrakis.es>.
  5.  * Webpage: http://www.arrakis.es/~worm/
  6.  *
  7.  * chkdef.cmd - checks that a .def file has no conflicts and is properly
  8.  *        formatted.
  9.  *
  10.  * returns nonzero if two symbols have the same code or a line has a wrong
  11.  * format.
  12.  *
  13.  * returns 0 otherwise
  14.  *
  15.  * the standard output shows conflicts.
  16.  */
  17. parse arg def_file
  18.  
  19. def_file = translate(def_file,'\','/')
  20.  
  21. call CleanQueue
  22.  
  23. /*
  24.  * `cmp' is zero when the file is valid
  25.  * `codes' associates a name to a code
  26.  * `names' associates a code to a name
  27.  */
  28. cmp    = 0
  29. codes. = 0
  30. names. = ''
  31.  
  32. /*
  33.  * This sed expression cleans empty lines, comments and special .DEF
  34.  * commands, such as LIBRARY..., EXPORTS..., etc
  35.  */
  36. tidy_up  = '"s/[     ][     ]*/ /g;s/;.*//g;/^[ ]*$/d;/^[a-zA-Z]/d;"'
  37.  
  38. /*
  39.  * First we find all public symbols from the original DLL. All this
  40.  * information is pushed into a REXX private list with the RXQUEUE
  41.  * utility program.
  42.  */
  43. '@echo off'
  44. 'type' def_file '| sed' tidy_up '| sort | rxqueue'
  45.  
  46. do while queued() > 0
  47.    /*
  48.     * We retrieve the symbol name (NEW_NAME) and its code (NEW_CODE)
  49.     */
  50.    parse pull '"' new_name '"' '@'new_code rest
  51.    select
  52.       when (new_code = '') | (new_name = '') then
  53.          /* The input was not properly formatted */
  54.          do
  55.          say 'Error: symbol "'new_name'" has no export code or is empty'
  56.          cmp = 1
  57.          end
  58.       when codes.new_name \= 0 then
  59.          /* This symbol was already defined */
  60.          if codes.new_name \= new_code then
  61.             do
  62.         cmp = 2
  63.          say 'Symbol "'new_name'" multiply defined'
  64.         end
  65.       when names.new_code \= '' then
  66.          /* This code was already assigned to a symbol */
  67.          if names.new_code \= new_name then
  68.             do
  69.             cmp = 3
  70.         say 'Conflict with "'names.new_code'" & "'new_name'" being @'new_code
  71.             end
  72.       otherwise
  73.          do
  74.          codes.new_name = new_code
  75.          names.new_code = new_name
  76.          end
  77.    end  /* select */
  78. end
  79.  
  80. exit cmp
  81.  
  82. CleanQueue: procedure
  83.     do while queued() > 0
  84.        parse pull foo
  85.     end
  86. return
  87.